<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="JQuerys/jquery-3.6.0.min.js"></script>
</head>
<body>

<button onclick="fun2()">点击发送AJAX请求</button>
<div id="d"></div>

<script>
    function  fun1() {
        //创建xmlhttprequest请求
        let xmlHttpRequest = new XMLHttpRequest();
        //状态发生变化调用这个回调函数
        //一般我们只关心状态变为4的时候

        xmlHttpRequest.onreadystatechange = function(){
            if(xmlHttpRequest.readyState==4){

                alert("回调函数启用")
            }
        }
        //打包数据
        xmlHttpRequest.open("get","/s1");
        xmlHttpRequest.send(null);
    }
    function fun2() {
            $.ajax({
            url:"/s1",
            type:"get",
            data: "name=zhangsan&password=123",
            success:function (result) {
                // $("#d").html(result)
                let parse = JSON.parse(result);
                let name = result.name;
                let password = result.password;
                $("#d").html("姓名"+name+"<br>"+"密码"+password)
            },
            error:function () {
                $("#d").html("页面出错了！")
            }


        })


    }




</script>

</body>
</html>